#ifndef PRINTPREVIEW_H
#define PRINTPREVIEW_H

#include <QWidget>
#include <QMutex>
#include <QWaitCondition>
#include <QThreadPool>
#include <QSharedPointer>
#include <QImage>
#include <QMap>
#include <piocore.h>
#include <mediaitem.h>

/*class PrintPreview : public QWidget
{
    Q_OBJECT
public:
    explicit PrintPreview(PioCore * core, QWidget * parent = 0);
    virtual ~PrintPreview();

signals:
    void pages(int pages);

public slots:
    void setSelection(QList<MediaItemPtr> selection);
    void setScrollArea(QSize size);
    void previousPage();
    void nextPage();
    void zoom(double zoom);
    void zoomIn();
    void zoomOut();
    void setPaperSize(double width, double height);
    void setAutoRotate(bool rotate);

protected:
    void paintEvent(QPaintEvent *);

private:
    void updateSize();
    void setup();
    double toCentimeters(int pixels);
    int toPixels(double centimeters);
    void run();

    class Thread : public QThread
    {
    public:
        Thread(PrintPreview * preview);
    protected:
        virtual void run();
    private:
        PrintPreview * m_preview;
    };

    struct ImageRow {
        QVector<QImage> images;
        double width, height, hspace;
        int page;
    };
    struct ImageInfo {
        ImageInfo() : rotated(false) {}
        QImage image;
        bool rotated;
        bool portrait;
    };

    PioCore * m_core;
    QList<MediaItem::Metadata> m_selection;
    QMap<QString, ImageInfo> m_images;
    QVector<ImageRow> m_rows;
    QMutex m_mutex;
    QWaitCondition m_cond;
    double m_width;
    double m_height;
    double m_zoom;
    int m_page_count;
    int m_page;
    bool m_quit;
    QSize m_scrollarea;
    Thread m_thread;
    double m_paper_width;
    double m_paper_height;
    bool m_autorotate;
};*/

#endif // PRINTPREVIEW_H
